package com.orange.server.user.controller;

import com.alibaba.fastjson.JSONObject;
import com.orange.common.exception.CustomerException;
import com.orange.common.exception.result.ResultSet;
import com.orange.server.user.entity.User;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.hibernate.validator.constraints.Length;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;


/**
 * @author : kyc
 * @Description: 用户
 * @date : 2021-02-04 09:37
 **/
@Validated
@RestController
@RequestMapping(value = "/user")
@Api(tags = "用户")
public class UserController {

    @ApiOperation("测试swagger")
    @GetMapping(value = "/getUser")
    public User getUser(@RequestParam String id) {
        User user = new User();
        user.setUserId("111");
        user.setUsername("大聪明");
        user.setPassword("666666");
        return user;
    }

    @ApiOperation(value = "测试异常-校验参数异常")
    @GetMapping(value = "/testException")
    public ResultSet<String> test01(@Length(max = 2,message = "长度>3") @RequestParam String id) {
        return ResultSet.success();
    }
}
